#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using MilwormsGameData;
#endregion

namespace MilwormsGame
{
    class ForceDemScreen : GameScreen
    {
        Texture2D planeTexture;
        private Texture2D fadeTexture;
        Vector2 planePos = new Vector2(260, 600);
        public static bool IsActive = false;
        public int licznik = 0;

        public ForceDemScreen() : base()
        {
            IsActive = true;
            this.IsPopup = true;
            // start the menu music
            AudioManager.PushMusic("F-16", false);
        }


        public override void LoadContent()
        {

            base.LoadContent();
            ContentManager content = ScreenManager.Game.Content;
            fadeTexture =
                content.Load<Texture2D>(@"Textures\GameScreens\FadeScreen");
            planeTexture = content.Load<Texture2D>(@"Textures\Characters\plane");
        }
    
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            licznik++;
            planePos.Y = planePos.Y - 5;
            if (planePos.Y + planeTexture.Height < -100 && licznik > 180)
            {
                AudioManager.PopMusic();
                this.ExitScreen();
            }
        }

        public override void Draw(GameTime gameTime)
        {
            if (!ForceDemScreen.IsActive)
            {
                return;
            }
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            spriteBatch.Begin();

            var fadePosition = new Vector2(ScreenManager.Game.GraphicsDevice.Viewport.Bounds.X,
                ScreenManager.Game.GraphicsDevice.Viewport.Bounds.Y);

            spriteBatch.Draw(fadeTexture,
                new Rectangle(0, 0, ScreenManager.Game.GraphicsDevice.Viewport.Width,
                    ScreenManager.Game.GraphicsDevice.Viewport.Height),
                Color.Black);
            
            spriteBatch.Draw(planeTexture, planePos, null, Color.White, 0f,
                Vector2.Zero, ScaledVector2.DrawFactor, SpriteEffects.None, 0f);
            spriteBatch.End();
        }


    }
}
